package com.googlecode.garbagecan.beanutils;

import java.util.Calendar;

import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.LazyDynaBean;
import org.apache.commons.beanutils.WrapDynaBean;

public class DynaBeanExample {
	public static void main(String[] args) {
		DynaBeanExample example = new DynaBeanExample();
		example.testWrapDynaBean();
		example.testLazyDynaBean();
	}
	
	private void testWrapDynaBean() {
		User user = new User();
		user.setUsername("Mandy");
		user.setPassword("gogogo");
		user.setBirthday(Calendar.getInstance().getTime());
		DynaBean myBean = new WrapDynaBean(user);
		System.out.println(myBean.get("username"));
		System.out.println(myBean.get("password"));
		System.out.println(myBean.get("birthday"));
	}
	
	private void testLazyDynaBean() {
		DynaBean myBean = new LazyDynaBean(); 
		myBean.set("myProperty", "myValue");
		System.out.println(myBean.get("myProperty"));
	}
}
